var dtree;
var layer;
var $;
var element;
var util;
var form;
var laydate;
layui.extend({
    dtree: '/dTree/layui_ext/dtree/dtree'
}).use(['element','layer','util', 'dtree','jquery', 'form','laydate'], function(){
    dtree = layui.dtree;
    layer = layui.layer;
    $ = layui.jquery;
    element = layui.element;
    util = layui.util;
    form = layui.form;
    laydate = layui.laydate;
    laydate.render({
        elem: '#checkEndDate',
        type: 'datetime',
        trigger: 'click'
    });
    laydate.render({
        elem: '#chargeEndDate',
        type: 'datetime',
        trigger: 'click'
    });
    $.ajax({
        url:"/user/getCreateUser",
        type:"post",
        dataType:"json",
        data:{},
        success:function(data){
            alert("已成功回调，获取管理员信息");
            console.log(data);
            $("input[name=createUserName]").val(data.allName);
            $("input[name=createUser]").val(data.id);
            $("input[name=createDate]").val(data.lastDate);
            $("input[name=status]").val("draft");
            var status = $("input[name=status]").val();
            if(status=="draft"){
                $("input[name=statusName]").val("已提交");
            }else if (status=="under"){
                $("input[name=statusName]").val("已受理");
            }else{
                $("input[name=statusName]").val("状态不明");
            }
        }
    })
    form.on('radio(erweima)', function (data) {
        var checkSubpackage = data.value;
        if(checkSubpackage=='鏄�'){
            $("input[name=checkSubpackageLab]").removeAttr("disabled");
            $("input[name=checkSubpackageContent]").removeAttr("disabled");
            $("input[name=checkSubpackageContent]").attr("placeholder","璇疯緭鍏ュ垎鍖呭唴瀹�");
            $("input[name=checkSubpackageLab]").attr("placeholder","璇疯緭鍏ュ垎鍖呭疄楠屽");
        }else if(checkSubpackage=='鍚�'){
            $("input[name=checkSubpackageContent]").attr("disabled","disabled");
            $("input[name=checkSubpackageLab]").attr("disabled","disabled");
            $("input[name=checkSubpackageContent]").attr("placeholder","鏃犲垎鍖呭唴瀹�");
            $("input[name=checkSubpackageLab]").attr("placeholder","鏃犲垎鍖呭疄楠屽");
        }
    });
});

function findCustomer(){
    layer.open({
        type : 2,
        title : "濮旀墭鍗曚綅淇℃伅",
        area : [ '900px', '550px' ],
        maxmin: true,
        shade : 0,
        offset: 'auto',
        content :"/articletype/layer-sel-customer.html",
        success:function(){
        }
    })
}

function findSpares(){
    layer.open({
        type : 2,
        title : "濮旀墭鍗曚綅淇℃伅",
        area : [ '950px', '600px' ],
        maxmin: true,
        shade : 0,
        offset: 't',
        content :"/articletype/layer-sel-spares.html",
        success:function(){
        }
    })
}

function wancheng() {
    var form1 = $("#addForm").serialize();
    addForm(form1);
}
function addForm(vals){
    var sequenceno = $("#sequenceno").html();
    console.log(sequenceno);
    vals+="&sequenceno="+sequenceno;

    $.ajax({
        url:"/articletype/addStandingBill",
        type:"post",
        dataType:"json",
        data:vals,
        success:function(data){
            if(data){
                layer.msg("娣诲姞鎴愬姛");
                window.parent.getPjtTable();
            }else{
                layer.msg("娣诲姞澶辫触锛岃娉ㄦ剰涓嶈兘鏈夌┖鏁板€�");
                window.parent.getPjtTable();
            }
        }
    })
}
function quxiao(){
    var layer=parent.layer;
    window.parent.getPjtTable();
    layer.close(layer.index);
}